﻿using DalatCooking.Core;
using DalatCooking.Core.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_CourseDetail : System.Web.UI.UserControl
{
    public Course course;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        course = CourseManager.FindById(CourseID);
        Page.Title = (course != null) ? course.Name : "Not found";
        lblTitle.Text = (course != null) ? course.Name + " #" + course.CourseId : "Not found";
        lblBody.Text = (course != null) ? course.Body : "Not found";
        Category c = CategoryManager.FindById(course.CategoryId);
       
        lblCategoryName.Text = (c != null) ? c.Name : "Not found";
        pictureCate.Src = "" + ((c != null) ? c.Picture : "/uploads/images/noimage.png");

        imgPicture.Src = "" + ((c != null) ? c.Picture : "/uploads/images/noimage.png");
        imgPic.HRef = "" + ((c != null) ? c.Picture : "/uploads/images/noimage.png");
        imgPic.Title = "" + ((c != null) ? c.Name : "/uploads/images/noimage.png");
        lblDesc.Text = (c != null) ? c.Description : "Not found";

       // rptOrther.DataSource = CourseManager.FindAll().FindAll(t => t.CategoryId == course.CategoryId);
       // rptOrther.DataBind();

        Page.MetaDescription = Setting.String("SITE_METADESC");
        Page.MetaKeywords = Setting.String("SITE_METAKEYWORD");
      
    }
    public int CourseID
    {
        get
        {
            if (Request.QueryString["CourseID"] != null)
                return ConvertObject.ToInt(Server.HtmlEncode(Request.QueryString["CourseID"]));
            return -1;
        }
    }
}